package com.fastloan.core.shiro;

import com.kawins.result.ResultTo;
import com.kawins.shiro.temp.core.filter.UserAuthFilter;
import com.kawins.shiro.temp.core.result.ShiroResultEnum;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author rankai
 *         createTime 2017-12-2017/12/21 17:12
 */
public class ZyUserFilter extends UserAuthFilter {

    private static final String REQUEST_OPTIONS_METHOD = "OPTIONS";

    @Override
    protected Object noLoginStr() {
        return new ResultTo(ShiroResultEnum.NO_LOGIN.getCode(), ShiroResultEnum.NO_LOGIN.getMessage());
    }

    @Override
    protected boolean doAfter(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
        if (REQUEST_OPTIONS_METHOD.equalsIgnoreCase(httpServletRequest.getMethod())) {
            return false;
        }
        return true;
    }
}
